﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Management
{
    public partial class Input : Form
    {
        public Input()
        {
            InitializeComponent();
        }

        private string connectionString = "Data Source=D:\\Project\\VC\\Net\\Management\\STUManagement.db;Version=3;";
      


        private void button1_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection connection = new SQLiteConnection(connectionString))
            {
                connection.Open();
                // Assuming StudentID is an auto-increment primary key, you don't need to specify it.
                string addQuery = $"INSERT INTO Student (StudentName, Age, ClassID, Sex) " +
                                 $"VALUES ('{textBox2.Text}', {int.Parse(textBox3.Text)}, {int.Parse(textBox4.Text)}, '{textBox5.Text}')";

                using (SQLiteCommand command = new SQLiteCommand(addQuery, connection))
                {
                    command.ExecuteNonQuery();
                }

                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
            }
        }
    }
}
